package com.xx.pmis.services.implementations;

import java.util.List;

import com.xx.pmis.model.Present;
import com.xx.pmis.persistence.dao.PresentDAO;
import com.xx.pmis.services.PresentService;

public class PresentServiceImpl implements PresentService {
	PresentDAO presentDAO = null;

	public PresentServiceImpl(PresentDAO presentDAO) {
		super();
		this.presentDAO = presentDAO;
	}

	public void saveOrUpdatePresent(Present present) throws Exception {
		presentDAO.saveOrUpdate(present);
	}

	public void savePresent(Present present) throws Exception {
		presentDAO.save(present);
	}

	public void deletePresent(Present present) throws Exception {
		presentDAO.delete(present);
	}

	public Present getPresentByPresentID(String presentID) throws Exception {
		Present present = presentDAO.getPresentByPresentID(presentID);
		return present;
	}

	public List<Present> getAllPresentByCondition(String hql) throws Exception {
		List<Present> presents = presentDAO.getAllPresentByCondition(hql);
		return presents;
	}

	public List<Present> getAllPresentByConditionByPage(String hql, int currentPage, int lineSize) throws Exception {
		List<Present> presents = presentDAO.getAllPresentByConditionByPage(hql, currentPage, lineSize);
		return presents;
	}
	
	public int getCountOfPresentByCondition(String hql) throws Exception {
		return presentDAO.getAllPresentByCondition(hql).size();
	}

}
